package chap09;

import java.io.IOException;
import java.net.*;

public class UdpSend {
    public static void main(String[] args)throws IOException {
        DatagramSocket ds=null; //链接句柄
        DatagramPacket dp=null;//测试端口能力
        try{
            ds=new DatagramSocket(3000);
        }catch(SocketException ex){

        }
        String str="hello world";//发送的内容
        try{
            dp=new DatagramPacket(str.getBytes(),str.length(), InetAddress.getByName("localhost"),9000);
                //DatagramPacket(value,length,ip,prot)
        }catch(UnknownHostException ex1){
        }
        try {
            ds.send(dp);
        }catch(IOException e){
        }
        ds.close();
    }
}
